import 'package:components/lara_press_text.dart';
import 'package:flutter/material.dart';

class LaraPressAppBar extends StatelessWidget implements PreferredSizeWidget {
  final String title;
  final bool? centerTitle;
  final Widget? titleWidget;
  final double? titleSpacing;
  final bool isTransparent;
  const LaraPressAppBar({
    super.key,
    this.title = "",
    this.centerTitle,
    this.titleWidget,
    this.titleSpacing,
    this.isTransparent = false,
  });

  @override
  Widget build(BuildContext context) {
    return AppBar(
      titleSpacing: titleSpacing,
      backgroundColor: isTransparent ? Colors.transparent : null,
      foregroundColor: isTransparent ? Colors.white : null,
      iconTheme: Theme.of(context).appBarTheme.iconTheme!.copyWith(
        color: isTransparent ? Colors.white : null,
      ),
      title:
          titleWidget ??
          LaraPressText(text: title, type: LaraPressTextType.appBarTitle),
      centerTitle: centerTitle,
    );
  }

  @override
  Size get preferredSize => const Size.fromHeight(kToolbarHeight);
}
